﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="PostDetail.ascx.cs" Inherits="Modules_Posts_Controls_PostDetail" %>
<%@ Register Src="../../Captcha/NumCaptcha.ascx" TagName="NumCaptcha" TagPrefix="uc1" %>

<asp:Repeater ID="rpt" runat="server">
    <ItemTemplate>
        <div class="metadata">
            <div class="datetime">
                <span class="month">
                    <%#DateTime.Parse(Eval("CreatedDate").ToString()).ToString("MMM") %></span><span
                        class="date"><%#DateTime.Parse(Eval("CreatedDate").ToString()).ToString("dd")%></span>
            </div>
            <div class="metainfo" style="width: 535px; float: left">
                <h1>
                    <a title="Permanent Link to <%#Eval("Title") %>" rel="bookmark" href="<%#UrlBuilder.GetNewsDetail(Eval("TextId").ToString(),Eval("CreatedDate")) %>">
                        <%#Eval("Title") %></a></h1>
                <input id="hdfid" value='<%#Eval("Id") %>' type="hidden" />
                <div class="meta">
                    <span class="cat_icon"><a rel="category tag" title="View all posts in <%#Eval("TermTaxonomyName")%>"
                        href="<%#GetTermRelationshipsInfo(Eval("lsTermRelationships"))[1]%>">
                        <%#GetTermRelationshipsInfo(Eval("lsTermRelationships"))[0]%></a></span><%#GetCodeEdit(Eval("Id")) %><a <%=GetAvaliableDelete() %>> | </a><a href="#<%#Eval("Id") %>" class="delete" <%=GetAvaliableDelete() %>>Delete</a>
                    <span class="comm_icon"><a title="Jump to the comments" href="<%#UrlBuilder.GetNewsDetail(Eval("TextId").ToString(),Eval("CreatedDate")) %>"><%#Wp.BLL.TblCommentsManager.CreateInstant().NumCommentOfPost(Eval("Id").ToInt()) %> bình luận</a></span>
                    <br />
                    <div class="fb_edge_widget_with_comment fb_iframe_widget" style="float: left; padding-right: 20px; padding-top: 3px;">
                        <a name="fb_share" type="button_count" share_url='<%=Wp.BLL.TblOptionManager.CreateInstant().GetDomainName() + Request.RawUrl %>'></a>
                        <script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share"
                            type="text/javascript">
                        </script>
                    </div>
                    <div class="fb-like" data-send="false" data-layout="button_count" data-width="450" data-show-faces="true" style="float: left; padding-top: 2px;"></div>
                    <div class="fb_edge_widget_with_comment fb_iframe_widget" style="float: left">
                        <span class='st_plusone_hcount' displaytext='G+'></span>
                        <span class='st_twitter_hcount' displaytext='Tweet'></span>
                        <span class='st_email_hcount' displaytext='Email'></span>
                    </div>
                    <div style="clear: both"></div>

                    <script type="text/javascript">
                        $("li.share span").click(function () {
                            if ($(this).parent().children("ul").hasClass('sh')) {
                                $(this).parent().children("ul").hide();
                                $(this).parent().children("ul").removeClass('sh');
                            }
                            else {
                                $(this).parent().children("ul").show();
                                $(this).parent().children("ul").addClass('sh');
                            }


                        });
                        $(".close").click(function () {
                            $(this).parent().hide();
                            $(this).parent().removeClass('sh');
                        });

                    </script>
                </div>
            </div>
            <div class="clear">
            </div>
        </div>
        <div class="entry">
            <%#Eval("Description") %>
        </div>
        <div class="fb_edge_widget_with_comment fb_iframe_widget" style="float: left; padding-right: 20px; padding-top: 3px;">
            <a name="fb_share" type="button_count" share_url='<%=Wp.BLL.TblOptionManager.CreateInstant().GetDomainName() + Request.RawUrl %>'></a>
            <script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share"
                type="text/javascript">
            </script>
        </div>
        <div class="fb-like" data-send="false" data-layout="button_count" data-width="450" data-show-faces="true" style="float: left; padding-top: 2px;"></div>
        <div class="fb_edge_widget_with_comment fb_iframe_widget" style="float: left">
            <span class='st_plusone_hcount' displaytext='G+'></span>
            <span class='st_twitter_hcount' displaytext='Tweet'></span><span class='st_linkedin_hcount'
                displaytext='LinkedIn'></span><span class='st_email_hcount' displaytext='Email'></span>
        </div>
        <div style="clear: both"></div>
    </ItemTemplate>
</asp:Repeater>
<br />
<br />
<%--begin comment--%>
<h3 id="comments">Có
    <asp:Literal ID="LiteralCommnent" runat="server"></asp:Literal>
    phản hồi đến “<asp:Literal ID="LiteralTitle" runat="server"></asp:Literal>”</h3>

<ol class="commentlist">
    <asp:Repeater ID="rptComment" runat="server" OnItemDataBound="rptComment_ItemDataBound">
        <ItemTemplate>
            <li id='li<%#Eval("Id") %>' class="comment byuser comment-author-gayviet even thread-even depth-1 highlander-comment">
                <div class="comment-author vcard">
                    <h3 class="commenttitle">
                        <cite class="fn"><a class="url" rel="external nofollow" href="#"><%#Eval("Author") %></a></cite> <span class="says">đã nói</span> </h3>
                </div>
                <small class="comment-meta commentmetadata"><a href="#">Ngày <%#DateTime.Parse(Eval("CreatedDate").ToString()).ToString("dd/MM/yyyy lúc hh:mm ttt", System.Globalization.CultureInfo.CreateSpecificCulture("vi-VN")) %></a> </small>
                <p>
                    <%#Eval("Content") %>
                </p>
                <div class="reply">
                    <a href="#" class="comment-reply-link" idvalue="<%#Eval("Id") %>">Trả lời</a> <%#StrEdit(Eval("Id") ) %>
                </div>

                <asp:Repeater ID="rptchild" runat="server">
                    <HeaderTemplate>
                        <ul class="children">
                    </HeaderTemplate>
                    <ItemTemplate>
                        <li id='li<%#Eval("Id") %>' class="comment even depth-2 highlander-comment">
                            <div class="comment-author vcard">
                                <h3 class="commenttitle">
                                    <cite class="fn"><a class="url" rel="external nofollow" href="#"><%#Eval("Author") %></a></cite> <span class="says">đã nói</span></h3>
                            </div>
                            <small class="comment-meta commentmetadata"><a href="#">Ngày <%#DateTime.Parse(Eval("CreatedDate").ToString()).ToString("dd/MM/yyyy lúc hh:mm ttt", System.Globalization.CultureInfo.CreateSpecificCulture("vi-VN")) %></a> </small>
                            <p>
                                <%#Eval("Content") %>
                            </p>
                            <%--<div class="reply">
                                    <a href="#" class="comment-reply-link" idvalue="<%#Eval("Id") %>">Trả lời</a> 
                                </div>--%>
                            <%#StrEdit(Eval("Id") ) %>
                        </li>
                    </ItemTemplate>
                    <FooterTemplate>
                        </ul>
                    </FooterTemplate>
                </asp:Repeater>
            </li>
        </ItemTemplate>
    </asp:Repeater>
</ol>
<div id="respond" class="commentlist">
    <div>
        <div class="">
            <textarea id="comment" name="comment" placeholder="Enter your comment here..." style="height: 100px; overflow-y: hidden; width: 660px"></textarea>
        </div>
    </div>
    <div style="display: block;">
        <div>
            <div style="margin: 0; padding: 0">
                <%-- <div class="comment-form-avatar">
                    <a href="/" target="_blank">
                        <img src="" alt="Gravatar" width="25" class="no-grav">
                    </a>
                </div>--%>
                <%-- <div class="comment-form-fields" style="margin: 0">
                    <div class="comment-form-field comment-form-author">
                        <div class="comment-form-input">
                            <input id="author" name="author" type="text" value="" placeholder="Họ Tên">
                        </div>
                        <label class="form-l">Họ Tên (Bắt Buộc)</label>
                    </div>
                    <div class="comment-form-field comment-form-email">
                        <div class="comment-form-input">
                            <input id="email" name="email" type="email" value="" placeholder="Email"><label class="form-l">E-Mail (Bắt Buộc) <span style="color: #666666; font-weight: normal;">được giấu kín</span></label>
                        </div>
                    </div>

                    <div class="comment-form-field comment-form-url" style="display: none">
                        <div class="comment-form-input">
                            <input id="url" name="url" type="text" value="" placeholder="Trang web">
                        </div>
                    </div>
                </div>--%>
                <label class="form-l">Họ Tên (Bắt Buộc)</label>
                <input class="your-name" type="text" name="author" id="author" value="" size="42" tabindex="1">
                <label class="form-l">E-Mail (Bắt Buộc) <span style="color: #666666; font-weight: normal;">được giấu kín</span></label>
                <input class="your-email" type="text" name="email" id="email" value="" size="42" tabindex="2">
            </div>
        </div>
    </div>

    <div>
        <uc1:NumCaptcha ID="NumCaptcha1" runat="server" />
        <p class="form-submit" style="display: block;">
            <input name="submit" type="button" id="comment-submit" value="Gửi phản hồi">
        </p>
    </div>
</div>
<input type="hidden" id="hdfparentid" value="-1" />
<%--end comment--%>
<p class="tags">
    Tags
    <asp:Repeater ID="rptposttags" runat="server">
        <ItemTemplate>
            <a rel="tag" href="<%#UrlBuilder.GetTags(Eval("Slug").ToString()) %>" style="display: inline-table">
                <%#Eval("Name")%></a>
        </ItemTemplate>
    </asp:Repeater>
</p>

<div class="entry">
    <h3>Những bài viết nên xem:</h3>
    <ul>
        <asp:Repeater ID="rptviewmore" runat="server">
            <ItemTemplate>
                <li><a href="<%#UrlBuilder.GetNewsDetail(Eval("TextId").ToString(),Eval("CreatedDate")) %>"
                    rel="bookmark" title="Permanent Link to <%#Eval("Title") %>">
                    <%#Eval("Title") %></a></li>
            </ItemTemplate>
        </asp:Repeater>
    </ul>
</div>

<script type="text/javascript">

    $(document).ready(function () {
        var myJsComment = new JsComment();
        $("#comment-submit").click(function () {
            var comment_content = $("#comment").val();
            var comment_name = $("#author").val();
            var comment_mail = $("#email").val();
            var comment_url = $("#url").val();
            var PostID = $("#hdfid").val();
            var ParentID = $("#hdfparentid").val();
            var answer = $(".Answer").val();

            if (comment_content == "") {
                alert('Bạn chưa nhập nội dung!');
                return false;
            }
            if (comment_mail == "") {
                alert('Bạn chưa nhập email!');
                return false;
            }
            if (comment_name == "") {
                alert('Bạn chưa nhập tên!');
                return false;
            }
            if (answer == "") {
                alert('Bạn chưa trả lời câu hỏi ngẫu nhiên!');
                return false;
            }
            var validate = myJsComment.ValidateCaptcha(answer);
            if (validate == '') {
                var result = myJsComment.InsertComment(PostID, ParentID, comment_content, comment_mail, comment_name, comment_url, answer);
                if (result) {
                    alert('Cảm ơn bạn đã gửi bình luận!');
                    $("#comment").val('');
                    $("#author").val('');
                    $("#email").val('');
                    $("#url").val('');
                    $("#hdfid").val('');
                    $(".Answer").val('');
                }
            }
            else {
                alert(validate);
            }
        });
        $(".comment-reply-link").click(function () {
            $("#hdfparentid").val($(this).attr("idvalue"));
            $("#comment").focus();
            return false;
        });
        var myMenu = new Menu();
        $("a.delete").click(function () {
            var id = $(this).attr("ref");
            if (confirm('Are you sure to delete')) {
                var Id = $(this).attr("href").replace("#", "");
                var Id2 = myMenu.DeleteMenu(Id);
                if (Id2 == -1) {
                    alert("Error!");
                }
                else {
                    window.location = '/';

                }
                //$('#tag-' + Id).remove();
            }
            return false;
        });
    });

</script>

